﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TeamService.Access
{
    public class Member : IComparer, IComparable, IComparable<Member>, IEquatable<Member>, INotifyPropertyChanged
    {
        public Member()
        {
            Name = "未初始化";
            Phone = "未初始化";
            ;
            QQ = "未初始化";
            Title = "";
        }
        void Update(string name)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
        }

        int _id;
        public int Id {
            get => _id;
            set {
                _id = value;
                Update(nameof(Id));
            }
        }

        string _name;
        public string Name {

            get => _name;
            set {
                _name = value;
                Update(nameof(Name));
            }
        }

        string _phone;
        public string Phone {
            get => _phone;
            set {
                _phone = value;
                Update(nameof(Phone));
            }
        }


        string _qq;
        public string QQ {
            get => _qq;
            set {
                _qq = value;
                Update(nameof(QQ));
            }
        }

        string _title;
        public string Title {
            get => _title;
            set {
                _title = value;
                Update(nameof(Title));
            }
        }

        int _right;
        public int AuthorRight {
            get => _right;
            set {
                _right = value;
                Update(nameof(AuthorRight));
            }
        }


        public event PropertyChangedEventHandler PropertyChanged;

        public Int32 Compare(Object x, Object y)
        {
            return string.Compare((x as Member).Name, (y as Member).Name);
        }

        public Int32 CompareTo(Object obj)
        {
            return Name.CompareTo(obj);
        }

        public Int32 CompareTo(Member other)
        {
            return Name.CompareTo(other.Name);
        }

        public Boolean Equals(Member other)
        {
            return Name.Equals(other.Name);
        }

        public override Int32 GetHashCode()
        {
            return Name.GetHashCode();
        }
    }
}
